/**
 * @author kaho
 * @since 2021/3/2
 */
public class _303_区域和检索_数组不可变 {

    class NumArray {

        int[] preSum;
        public NumArray(int[] nums) {
            preSum = new int[nums.length+1];
            for (int i = 0; i < nums.length; i++) {
                preSum[i+1] = preSum[i]+nums[i];
            }
        }

        public int sumRange(int i, int j) {
            return preSum[j+1] - preSum[i];
        }
    }

}
